package GUI;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.TitledBorder;

import Entity.*;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Date;
import javax.swing.JTable;
/**
 * this is the GUI for order report creation. the parking lot manager will enter the dates, the description and the number details of orders.
 * @author Shahar Shelly
 */
public class OrderReportCreateWin extends JFrame {

	private JPanel contentPane;
	private JTextField startDate;
	private JTextField endDate;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_3;

	/**
	 * is the constructor. it has two buttons for cancel and submit and it will validate the information.
	 */
	public OrderReportCreateWin(OrderReport o) {
		final OrderReport o2=o;
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 389, 324);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		final JLabel lblOrderReport = new JLabel("Order Report");
		lblOrderReport.setBounds(136, 11, 93, 14);
		contentPane.add(lblOrderReport);
		
		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "Start Date", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(10, 33, 98, 43);
		contentPane.add(panel);
		panel.setLayout(null);
		
		startDate = new JTextField();
		startDate.setBounds(6, 16, 86, 20);
		panel.add(startDate);
		startDate.setColumns(10); 
		startDate.setText(o.getStart().getDate()+"/"+(o.getStart().getMonth()+1)+"/"+(o.getStart().getYear()+1900));
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "End Date", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.setBounds(10, 77, 98, 43);
		contentPane.add(panel_1);
		panel_1.setLayout(null);
		
		endDate = new JTextField();
		endDate.setBounds(6, 16, 86, 20);
		panel_1.add(endDate);
		endDate.setColumns(10);
		endDate.setText(o.getEndDate().getDate()+"/"+(o.getEndDate().getMonth()+1)+"/"+(o.getEndDate().getYear()+1900));
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(null, "Description", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_2.setBounds(118, 36, 221, 84);
		contentPane.add(panel_2);
		panel_2.setLayout(null);
		
		final JTextPane textPane = new JTextPane();
		textPane.setBounds(6, 16, 205, 57);
		panel_2.add(textPane);
		
		JButton btnSend = new JButton("Send");
		btnSend.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				o2.SetDescription(textPane.getText());
				JOptionPane.showMessageDialog(null,"Your Report was sent to the Company Manager","Sent Successfully",JOptionPane.INFORMATION_MESSAGE);
				OrderReport.save(o2);
			}
		});
		btnSend.setBounds(95, 251, 89, 23);
		contentPane.add(btnSend);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.setBounds(203, 251, 89, 23);
		contentPane.add(btnCancel);
		
		JLabel lblNumberOfOrders = new JLabel("Number of Orders:");
		lblNumberOfOrders.setBounds(10, 134, 98, 14);
		contentPane.add(lblNumberOfOrders);
		
		textField = new JTextField();
		textField.setBounds(203, 131, 48, 20);
		contentPane.add(textField);
		textField.setColumns(10);
		this.textField.setText(String.valueOf(o.getNumOfOrders()));
		
		JLabel lblNumberOfSubscriptions = new JLabel("Number of Subscriptions:");
		lblNumberOfSubscriptions.setBounds(10, 159, 186, 14);
		contentPane.add(lblNumberOfSubscriptions);
		
		JLabel lblNumberOfInadvance = new JLabel("Number of In-Advance orders:");
		lblNumberOfInadvance.setBounds(10, 184, 197, 14);
		contentPane.add(lblNumberOfInadvance);
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(203, 156, 48, 20);
		contentPane.add(textField_1);
		this.textField_1.setText(String.valueOf(o.getNumOfSubs()));
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		textField_3.setBounds(203, 181, 48, 20);
		contentPane.add(textField_3);
		this.textField_3.setText(String.valueOf(o.getNumOfInAdvance()));
	}
}
